{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from PIL import Image\n",
    "from pycocotools.coco import COCO\n",
    "from lxml import etree\n",
    "\n",
    "import cv2\n",
    "import sys\n",
    "import json\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "sys.path.insert(0, '../libs')\n",
    "\n",
    "from imantics import Dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('data/coco_example/tesla.json') as f:\n",
    "    data = json.load(f)\n",
    "\n",
    "dataset = Dataset.from_coco(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAD8CAYAAAB9y7/cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFc9JREFUeJzt3X+sXOV95/H3NzaG/CZ2Cuu1zfKjVrZV0xCECA5VxIa2G0gUIhRWpM3GRFRW+kukWak1Xe2uUuWPZrVqQtQVxArZJSUm0DQpFsomEBNr21VKYsAEU4diKIJbU9wtP6LdaNMQvvvHPAPD9Xju3Dtz5px57vslXc05Z86c+c7MM5955rnnnInMRJJUn1e0XYAkqRkGvCRVyoCXpEoZ8JJUKQNekiplwEtSpRoJ+Ih4V0Q8FBGHI2JnE/chSRotpr0ffESsAf4G+CVgAfgu8IHM/Oup3pEkaaQmevDnAYcz89HM/CfgS8ClDdyPJGmEtQ1scxPwxMD8AvC2UTeICA+nlaRFMjMmuX0TAT+soGMCPCJ2ADsauH9JEs0E/AKwZWB+M3Bk8UqZuQvYBfbgJakJTYzBfxfYGhFnRMQ64ApgTwP3I0kaYeo9+Mx8PiJ+C/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MXBvZj5V5tuq5xeBv83Mf8jMHwNfAd5O+23ohsw8JzPfUbb/MFN8jtoO+O8CW8t/stfR+yq3p6VaWjsyNyICuAE4lJl/1HZNEfFTEXFymX4lvTfHIeBbwPuPU0+/zvcDd2UZJJyGzLwmMzdn5un02shdmfmrbdUDEBGvjojX9qfpjTMfpKXXLLt7xPkHeGl4pn+/bdTzOHB+RLyqvN/6z09rbQggykkaI+I04DJ6z9X0nqNp/tNghf9ouITeXiOPAP9+Rvd5M71xuB/T+1S8it742l56n6B7gfVl3QD+a6nvAeDcBur5BXpftb4HHCh/l7RVE/DzwH2lnoPAfyzLzwS+Q+8o5T8FTizLTyrzh8v1Zzb42l3IS3vRtFZPue/7y9+D/bbbcjs6G9hfXrc/B97Qcj2vAv4ReP3Asjbr+Tjw/dKm/wQ4se02DfwFvQ+a+4GLpv0ceSSrJFWq7SEaSVJDDHhJqpQBL0mVMuAlqVIGvCRVyoCXpEoZ8JJUKQNekir1/wHBRaNLkJQxngAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for image in dataset.iter_images():\n",
    "    draw = image.draw(bbox=False)\n",
    "    plt.imshow(draw)\n",
    "    plt.show()\n",
    "    etree.tostring(image.export(style='voc'), pretty_print=True).decode('utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'categories': [{'id': 1, 'name': 'wheel', 'supercategory': None, 'metadata': {}, 'color': '#fa2200'}]}\n",
      "{'categories': [{'id': 2, 'name': 'glass', 'supercategory': None, 'metadata': {}, 'color': '#ac17e4'}]}\n"
     ]
    }
   ],
   "source": [
    "for category in dataset.iter_categories():\n",
    "    print(category.export())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"/datasets/Car/car/2015-tesla-model-s-90d-black-profile-in-front-of-modern-house.jpg\": [\n",
      "        \"1 0.26889 0.51667 0.66000 0.24667\",\n",
      "        \"2 0.29222 0.31333 0.50778 0.11333\"\n",
      "    ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "print(json.dumps(dataset.yolo(), indent=4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"info\": {},\n",
      "    \"categories\": [\n",
      "        {\n",
      "            \"id\": 1,\n",
      "            \"name\": \"wheel\",\n",
      "            \"supercategory\": null,\n",
      "            \"metadata\": {},\n",
      "            \"color\": \"#fa2200\"\n",
      "        },\n",
      "        {\n",
      "            \"id\": 2,\n",
      "            \"name\": \"glass\",\n",
      "            \"supercategory\": null,\n",
      "            \"metadata\": {},\n",
      "            \"color\": \"#ac17e4\"\n",
      "        }\n",
      "    ],\n",
      "    \"images\": [\n",
      "        {\n",
      "            \"id\": 36,\n",
      "            \"width\": 900,\n",
      "            \"height\": 600,\n",
      "            \"file_name\": \"2015-tesla-model-s-90d-black-profile-in-front-of-modern-house.jpg\",\n",
      "            \"path\": \"/datasets/Car/car/2015-tesla-model-s-90d-black-profile-in-front-of-modern-house.jpg\",\n",
      "            \"license\": null,\n",
      "            \"fickr_url\": null,\n",
      "            \"coco_url\": null,\n",
      "            \"date_captured\": null,\n",
      "            \"metadata\": {\n",
      "                \"license\": null,\n",
      "                \"flickr_url\": null,\n",
      "                \"coco_url\": null,\n",
      "                \"date_captured\": null\n",
      "            }\n",
      "        }\n",
      "    ],\n",
      "    \"annotations\": [\n",
      "        {\n",
      "            \"id\": 1,\n",
      "            \"image_id\": 36,\n",
      "            \"category_id\": 1,\n",
      "            \"width\": 900,\n",
      "            \"height\": 600,\n",
      "            \"area\": 27763,\n",
      "            \"segmentation\": [\n",
      "                [\n",
      "                    820.1,\n",
      "                    326.7,\n",
      "                    827.3,\n",
      "                    338.9,\n",
      "                    834.8,\n",
      "                    361.3,\n",
      "                    836.1,\n",
      "                    368.7,\n",
      "                    836.0,\n",
      "                    376.0,\n",
      "                    835.5,\n",
      "                    381.7,\n",
      "                    835.1,\n",
      "                    387.3,\n",
      "                    834.1,\n",
      "                    391.6,\n",
      "                    828.1,\n",
      "                    409.4,\n",
      "                    808.3,\n",
      "                    433.3,\n",
      "                    796.4,\n",
      "                    437.6,\n",
      "                    774.7,\n",
      "                    438.0,\n",
      "                    764.1,\n",
      "                    437.3,\n",
      "                    743.2,\n",
      "                    437.8,\n",
      "                    726.2,\n",
      "                    416.8,\n",
      "                    730.6,\n",
      "                    401.3,\n",
      "                    729.1,\n",
      "                    394.1,\n",
      "                    727.5,\n",
      "                    378.5,\n",
      "                    734.8,\n",
      "                    348.2,\n",
      "                    739.4,\n",
      "                    337.9,\n",
      "                    754.9,\n",
      "                    319.4,\n",
      "                    764.2,\n",
      "                    313.3,\n",
      "                    775.6,\n",
      "                    311.1,\n",
      "                    801.8,\n",
      "                    312.2,\n",
      "                    809.1,\n",
      "                    315.4,\n",
      "                    815.3,\n",
      "                    320.3,\n",
      "                    819.9,\n",
      "                    326.6\n",
      "                ],\n",
      "                [\n",
      "                    264.3,\n",
      "                    330.9,\n",
      "                    270.7,\n",
      "                    321.4,\n",
      "                    280.3,\n",
      "                    314.9,\n",
      "                    290.4,\n",
      "                    310.7,\n",
      "                    301.1,\n",
      "                    309.9,\n",
      "                    315.9,\n",
      "                    311.1,\n",
      "                    331.6,\n",
      "                    315.3,\n",
      "                    344.5,\n",
      "                    322.1,\n",
      "                    355.4,\n",
      "                    331.4,\n",
      "                    366.2,\n",
      "                    347.9,\n",
      "                    372.4,\n",
      "                    362.4,\n",
      "                    375.3,\n",
      "                    388.9,\n",
      "                    373.0,\n",
      "                    405.7,\n",
      "                    367.8,\n",
      "                    421.1,\n",
      "                    359.3,\n",
      "                    433.1,\n",
      "                    343.7,\n",
      "                    448.4,\n",
      "                    327.3,\n",
      "                    455.3,\n",
      "                    288.1,\n",
      "                    458.3,\n",
      "                    263.7,\n",
      "                    453.1,\n",
      "                    254.9,\n",
      "                    448.1,\n",
      "                    241.7,\n",
      "                    434.5,\n",
      "                    242.5,\n",
      "                    392.8,\n",
      "                    244.8,\n",
      "                    367.9,\n",
      "                    249.8,\n",
      "                    351.3,\n",
      "                    263.7,\n",
      "                    333.9\n",
      "                ]\n",
      "            ],\n",
      "            \"bbox\": [\n",
      "                242,\n",
      "                310,\n",
      "                594,\n",
      "                148\n",
      "            ],\n",
      "            \"metadata\": {},\n",
      "            \"color\": \"#a42559\"\n",
      "        },\n",
      "        {\n",
      "            \"id\": 2,\n",
      "            \"image_id\": 36,\n",
      "            \"category_id\": 2,\n",
      "            \"width\": 900,\n",
      "            \"height\": 600,\n",
      "            \"area\": 19422,\n",
      "            \"segmentation\": [\n",
      "                [\n",
      "                    615.5,\n",
      "                    188.5,\n",
      "                    653.5,\n",
      "                    192.5,\n",
      "                    689.5,\n",
      "                    199.5,\n",
      "                    708.5,\n",
      "                    222.5,\n",
      "                    719.5,\n",
      "                    241.5,\n",
      "                    690.5,\n",
      "                    246.5,\n",
      "                    651.5,\n",
      "                    250.5,\n",
      "                    617.5,\n",
      "                    251.5,\n",
      "                    617.5,\n",
      "                    236.5,\n",
      "                    610.5,\n",
      "                    196.5,\n",
      "                    610.5,\n",
      "                    188.5\n",
      "                ],\n",
      "                [\n",
      "                    592.5,\n",
      "                    188.5,\n",
      "                    593.5,\n",
      "                    228.5,\n",
      "                    591.5,\n",
      "                    253.5,\n",
      "                    521.5,\n",
      "                    256.5,\n",
      "                    521.5,\n",
      "                    251.5,\n",
      "                    524.5,\n",
      "                    249.5,\n",
      "                    524.5,\n",
      "                    245.5,\n",
      "                    522.5,\n",
      "                    243.5,\n",
      "                    510.5,\n",
      "                    243.5,\n",
      "                    510.5,\n",
      "                    240.5,\n",
      "                    512.5,\n",
      "                    239.5,\n",
      "                    510.5,\n",
      "                    237.5,\n",
      "                    490.5,\n",
      "                    234.5,\n",
      "                    478.5,\n",
      "                    235.5,\n",
      "                    471.5,\n",
      "                    238.5,\n",
      "                    467.5,\n",
      "                    238.5,\n",
      "                    468.5,\n",
      "                    230.6,\n",
      "                    511.5,\n",
      "                    203.5,\n",
      "                    540.5,\n",
      "                    193.5,\n",
      "                    576.5,\n",
      "                    188.5\n",
      "                ],\n",
      "                [\n",
      "                    430.5,\n",
      "                    232.5,\n",
      "                    398.5,\n",
      "                    249.5,\n",
      "                    386.6,\n",
      "                    253.9,\n",
      "                    343.2,\n",
      "                    254.0,\n",
      "                    320.4,\n",
      "                    251.4,\n",
      "                    295.3,\n",
      "                    253.1,\n",
      "                    272.0,\n",
      "                    252.3,\n",
      "                    268.1,\n",
      "                    253.7,\n",
      "                    264.6,\n",
      "                    252.2,\n",
      "                    263.1,\n",
      "                    248.7,\n",
      "                    264.6,\n",
      "                    245.2,\n",
      "                    274.1,\n",
      "                    239.0,\n",
      "                    301.9,\n",
      "                    228.6,\n",
      "                    303.8,\n",
      "                    225.6,\n",
      "                    316.8,\n",
      "                    220.5,\n",
      "                    319.0,\n",
      "                    220.9,\n",
      "                    379.0,\n",
      "                    197.0,\n",
      "                    403.8,\n",
      "                    189.9,\n",
      "                    443.6,\n",
      "                    187.5,\n",
      "                    504.5,\n",
      "                    188.4,\n",
      "                    476.3,\n",
      "                    203.5\n",
      "                ]\n",
      "            ],\n",
      "            \"bbox\": [\n",
      "                263,\n",
      "                188,\n",
      "                457,\n",
      "                68\n",
      "            ],\n",
      "            \"metadata\": {},\n",
      "            \"color\": \"#b403dd\"\n",
      "        }\n",
      "    ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "print(json.dumps(dataset.coco(), indent=4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2333'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
